|
A tree sort is a sort algorithm that builds a binary search tree from the keys to be sorted, and then traverses the tree (in-order) so that the keys come out in sorted order. Its typical use is sorting elements adaptively: after each insertion, the set of elements seen so far is available in sorted order. == Efficiency == Adding one item to a binary search tree is on average an process (in big O notation), so adding n items is an process, making tree sort a 'fast sort'. But adding an item to an unbalanced binary tree needs time in the worst-case, when the tree resembles a linked list (degenerate tree), causing a worst case of for this sorting algorithm. This worst case occurs when the algorithm operates on an already sorted set, or one that is nearly sorted. Expected time can however be achieved in this case by shuffling the array. The worst-case behaviour can be improved upon by using a self-balancing binary search tree. Using such a tree, the algorithm has an worst-case performance, thus being degree-optimal for a comparison sort. When using a splay tree as the binary search tree, the resulting algorithm (called splaysort) has the additional property that it is an adaptive sort, meaning that its running time is faster than for inputs that are nearly sorted. 抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)』 ■ウィキペディアで「Tree sort」の詳細全文を読む スポンサード リンク
|